package 力扣题库;

import java.util.ArrayList;
import java.util.List;

public class p145二叉树的后序遍历 {
    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> res=new ArrayList<>();
        if (root==null) {
            return res;
        }

        List<Integer> leftTree=postorderTraversal(root.left);
        res.addAll(leftTree);

        List<Integer> rightTree=postorderTraversal(root.right);
        res.addAll(rightTree);

        res.add(root.val);

        return res;
    }
}
